import { ShineBlueSkinCellRenderer } from "../../common/item/ShineBlueSkinCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { BaseItem } from "../../common/BaseItem";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { MountEquipCellInfo } from "../mountEquip/MountEquipCellInfo";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { Language } from "../../../../../extend/language/Language";
import { MountUtil } from "../../../scene/mount/MountUtil";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ItemData } from "../../../resource/info/ItemData";
type int = number;
//class MountEquipCellRender
    
    export  class MountEquipCellRender extends ShineBlueSkinCellRenderer
    {
        constructor()
        {
            super();
            this.buttonMode = true;
            this.useHandCursor = true;
            this.mouseChildren = true;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 153, 48, this, ImagesConst.DisabledBg);
            ObjCreate.createBg(2, 3, 38, 38, this, ImagesConst.PackItemBg);
            this._baseItem = new BaseItem();
            this._baseItem.move(4, 6);
            this._baseItem.setSize(32, 32);
            addChild(this._baseItem);
            this._nameTxt = ObjCreate.createTextField("", 43, 3, 110, 20, this);
            this._lvTx = ObjCreate.createGTextField("", 43, 23, 100, 20, this, GlobalStyle.textFormat5);
            this._equipNullBm = ObjCreate.createBitmap("", 3, 5, this);
            LoaderHelp.addResCallBack(ResFileConst.mountEquip, this.onLoadBmResource);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._loaded = true;
            if (this._equipNullBm.visible) 
            {
                this.setequipNullBm(this._equipType);
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._info = arg1 as MountEquipCellInfo;
            if (this._info) 
            {
                this._itemData = this._info.idata;
                this._equipType = this._info.equipType;
                if (this._itemData && this._itemData.itemExInfo) 
                {
                    this._baseItem.itemData = this._itemData;
                    this._nameTxt.htmlText = ItemsUtil.getItemName(this._itemData);
                    this._lvTx.text = Language.getString(61323) + "  " + this._itemData.itemExInfo.m_equip_star;
                    this._equipNullBm.visible = false;
                }
                else 
                {
                    this._nameTxt.htmlText = "<font color=\'#888888\'>" + MountUtil.instance.getMountEquipName(this._equipType) + "</font>";
                    this._lvTx.text = "";
                    this._baseItem.itemData = null;
                    this._equipNullBm.visible = true;
                    this.setequipNullBm(this._equipType);
                }
            }
            else 
            {
                this.clean();
            }
            return;
        }

        /* internal  */clean(): void
        {
            this._nameTxt.htmlText = "";
            this._lvTx.text = "";
            this._baseItem.itemData = null;
            this.setequipNullBm(0);
            return;
        }

        /* internal  */setequipNullBm(arg1: int): void
        {
            if (this._loaded) 
            {
                if (arg1 > 0 && arg1 < 5) 
                {
                    this._equipNullBm.bitmapData = GlobalClass.getBitmapData("mouintEquip_" + arg1);
                }
                else 
                {
                    this._equipNullBm.bitmapData = null;
                }
            }
            return;
        }

        /* internal */ /* var */_itemData: ItemData;

        /* internal */ /* var */_equipType: int;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_lvTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_equipNullBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_info: MountEquipCellInfo;

        /* internal */ /* var */_loaded: Boolean;
    }
